package zheezes.protocol.impl.gbw.afn8d;

import zheezes.protocol.impl.gbw.format.DataForm20;
import zheezes.protocol.impl.gbw.format.DataForm34;

public class Afn8DDownF1S1DataUnit extends Afn8DDownF1DataUnit {
	private DataForm34 type = new DataForm34();
	private byte days;
	private DataForm20 sdate = new DataForm20(); // start date

	@Override
	public int sizeOfData() {
		return 1 + 1 + sdate.sizeof();
	}

	@Override
	public int getData(byte[] buf, int offset) {
		int idx = offset;
		idx += type.getBytes(buf, idx);
		buf[idx++] = days;
		idx += sdate.getBytes(buf, idx);
		idx += 3;

		return idx - offset;
	}

	@Override
	public int setData(byte[] buf, int offset, int max) {
		int idx = offset;
		idx += type.setBytes(buf, idx);
		days = buf[idx++];
		idx += sdate.setBytes(buf, idx);

		return idx - offset;
	}

	public DataForm34 getType() {
		return type;
	}

	public void setType(DataForm34 type) {
		this.type = type;
	}

	public byte getDays() {
		return days;
	}

	public void setDays(byte days) {
		this.days = days;
	}

	public DataForm20 getSdate() {
		return sdate;
	}

	public void setSdate(DataForm20 sdate) {
		this.sdate = sdate;
	}
}
